snippet cl "Description" w
class $1 {
public:
	>++>
};
endsnippet

snippet qmi "Description" w
// 快速幂
ll qmi(ll a, ll b, ll p) {
	ll ret = 1;
	while (b) {
		if (b & 1) {
			ret = (ret * a) % p;
		}
		b >>= 1;
		a = a * a % p;
	}
	return ret % p;
}
endsnippet

snippet swdp "Description" w
// 数位DP
ll count(int n, int x) {
	vector<int>nums;
	int t = n;
	while (t) {
		nums.push_back(t % 10);
		t /= 10;
	}
	int len = nums.size();
	ll ret = 0;
	ll pre = 0;
	ll lat = pow(10, len-1);
	for (int i = len-1; i >= 0; i--){
		ret += (pre * lat);
		if (i != len-1 && x == 0) { // 0不能做首位
			ret -= lat;
		}
		int t = nums[i];
		if (t > x && !(pre == 0 && x == 0)) { // 0不能做首位
			ret += lat;
		} else if (t == x){
			ret += (n % lat) + 1;
		}
		// printf("ret = %d\n", ret);
		pre = pre * 10 + t;
		lat /= 10;
	}
	if (x == 0) { // single '0' is omitted, add it
		ret ++;
	}
	return ret;
}
endsnippet

snippet ima "Description" w
INT_MAX
endsnippet

snippet imi "Description" w
INT_MIN
endsnippet

snippet ina "Description" b
#include <$1>
endsnippet

snippet inb "Description" b
#include "$1"
endsnippet

snippet inc "Description" b
#include $1
endsnippet

snippet si "Description" w
size()
endsnippet

snippet en "Description" w
end()
endsnippet

snippet be "Description" w
begin()
endsnippet

snippet al "NormalAlgorithmProblem" b
#include <iostream>
#include <climits>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <unordered_map>
#include <map>
#include <string.h>

using namespace std;
using pii = pair<int, int>;
using vii = vector<int>;
using ll = long long;
const int IMAX = INT_MAX;
void Init();
void Redirect();

${1:}

void Init(){
	>++>
}

int main(){
	// auto start_clock = clock();
	Init();
	// auto end_clock = clock();
	// cout << "runtime: "<< end_clock - start_clock << "ms" << endl;
	return 0;
}

void Redirect(){
	freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
}
endsnippet

snippet f "MyFor" b
for (${1}; >++>; >++>){
	>++>
}
endsnippet

snippet sol "Description" b
void solve()
{
	${1:}
}
endsnippet

snippet imi "Description" w
INT_MIN
endsnippet

snippet ima "Description" w
INT_MAX
endsnippet

snippet les "Description" w
struct TreeNode {
	int val;
	TreeNode *left;
	TreeNode *right;
	TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};

TreeNode* deserialize(string data) {
	if (data.size() == 0) {
		return nullptr;
	}
	string str;
	list<string>lst;
	for (auto &c: data) {
		if (c == '[') {
			continue;
		} else if (c == ',' || c == ']') {
			lst.push_back(str);
			str.clear();
		} else {
			str += c;
		}
	}
	auto it = lst.begin();
	it++;
	queue<TreeNode*>que;
	auto root = new TreeNode(stoi(lst.front()));
	que.push(root);
	while (que.size() && it != lst.end()) {
		int len = que.size();
		for (int i = 0; i < len; i++){
			auto f = que.front();
			que.pop();
			if (*it != "null") {
			// if (it != lst.end() && *it != "null") {
				auto p = new TreeNode(stoi(*it));
				f->left = p;
				que.push(p);
			}
			it++;
			if (*it != "null") {
				auto p = new TreeNode(stoi(*it));
				f->right = p;
				que.push(p);
			}
			it++;
		}
	}
	return root;
}
endsnippet

snippet s "MyScanf" b
scanf("${1}", &>++>);
endsnippet

snippet p "MyPintf" w
printf("${1}">++>);
endsnippet

snippet str "MyStruct" b
struct ${1}{
	>++>
}>++>;
endsnippet

snippet ope "stuctOperator" b
bool operator${1}(const >++> x) const{
	>++>
}
endsnippet

snippet mypow "Description" b
int mypow(int a, int b){
	if(b <= 2) return (a * a)%MOD;
	int ret1, ret2 = a, cnt1 = log(b)/log(2);
	int cnt2 = b - pow(2, cnt1);
	for(int i = 0; i < cnt1; ++i) ret2 = (ret2 * ret2)%MOD;
	return (jjpow(a, cnt2) * ret2)%MOD;
}
endsnippet

snippet myc "Description" b
int jjC(ll a, ll b){
	int ret = 1, tmp = 1;
	for(int i = a; i > a - b; --i) ret = (ret * i)%MOD;
	for(int i = 2; i <= b; ++i) tmp = (tmp * i)%MOD;
	return ret/tmp;
}
endsnippet

# A valid snippet should starts with:
#
#		snippet trigger_word [ "description" [ options ] ]
#
# and end with:
#
#		endsnippet
#
# Snippet options:
#
#		b - Beginning of line.
#		i - In-word expansion.
#		w - Word boundary.
#		r - Regular expression
#		e - Custom context snippet
#		A - Snippet will be triggered automatically, when condition matches.
#
# Basic example:
#
#		snippet emitter "emitter properties" b
#		private readonly ${1} = new Emitter<$2>()
#		public readonly ${1/^_(.*)/$1/}: Event<$2> = this.$1.event
#		endsnippet
#
# Online reference: https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt
